var h = $(window).height(),
    flag = true,
    benginTime = '',
    endTime = '';
    $('.row').css({height: h + 'px', overflow: 'hidden'});
    $('.newStyle').css({height: h - 20 + 'px'});
    $('.overScroll').css({height: h - 250 + 'px',overflow: 'auto'});
var num = Math.floor($('.overScroll').height() / 36);
    $(window).resize(function(){
        h = $(window).height();
        $('.row').css({height: h + 'px', overflow: 'hidden'});
        $('.newStyle').css({height: h - 20 + 'px'});
        $('.overScroll').css({height: h - 250 + 'px',overflow: 'auto'});
        num = Math.floor($('.overScroll').height() / 36);
    })
//日期
var now3 = new Date();
var now4 = new Date()
$('#widgetCalendar').DatePicker({
    flat: true,
    format: 'Y-m-d',
    date: [new Date(now3), new Date(now4)],
    calendars: 2,
    mode: 'range',
    starts: 1,
    onChange: function(formated) {
        benginTime = formated[0] + ' 00:00:00';
        endTime = formated[1] + ' 23:59:59';
        $('#time').val(formated.join(' 至 '));
    }
});
function closeData(){
    $('#widgetCalendar').stop().animate({height: 0}, 500);
    flag = true;
}
function nulls(item){
    var callback;
    if(item != null && item != undefined){
        callback = item;
    } else {
        callback = '无';
    }
    return callback;
}
function dateTimePicker(){
    stopPro(event);
 if(flag){
     $('#widgetCalendar').stop().animate({height: 500}, 500);
     flag = false;
 }else{
     $('#widgetCalendar').stop().animate({height: 0}, 500);
     flag = true;
 }
}
function stopPro(event){
    var e = arguments.callee.caller.arguments[0]||event;
    if (e && e.stopPropagation) {
        e.stopPropagation();
    } else if (window.event) {
        window.event.cancelBubble = true;
    }
}
function delCalender(item){
    $(item).parent().find('input').val('');
    benginTime = '';
    endTime = '';
}
function checked(){
    console.log(num);
    $.ajax({
    type: 'get',
    url: baseUrls + 'logs',
    data: {pageSize: num, pageIndex: 1, usercode: $('.case-hoof').val(), name: $('.name-hoof').val(), benginTime: benginTime, endTime: endTime},
    beforeSend: function () {
        Loading();
    },
    success: function (response){
        closeLoading();
        if(response.responseCode == '1000'){
            if(response.content.list.length > 0){
                $('#ul-content').html('');
                for(var i = 0; i < response.content.list.length; i++){
                    $('#ul-content').append('<li><span class="name" title="'+ nulls(response.content.list[i].usercode) +'">'+ nulls(response.content.list[i].usercode) +'</span><span class="ip" title="'+ nulls(response.content.list[i].ip) +'">'+ nulls(response.content.list[i].ip) +'</span><span class="content" title="'+ nulls(response.content.list[i].rzms) +'">'+ nulls(response.content.list[i].rzms) +'</span><span class="time" title="'+ nulls(response.content.list[i].czsj) +'">'+ nulls(response.content.list[i].czsj) +'</span></li>');
                }
                $('#demo_pag1').show();
                $('#demo_pag1').bs_pagination({
                    totalPages: response.content.pages,
                    visiblePageLinks: 10,
                    currentPage: response.content.pageNum,
                    showGoToPage: false,
                    showRowsPerPage: false,
                    showRowsInfo: false,
                    showRowsDefaultInfo: false,
                    navListContainerClass: 'col-xs-12',
                    onChangePage: function (event, data) {
                        $.ajax({
                            type: 'get',
                            url: baseUrls + 'logs',
                            data: {pageSize: num,pageIndex: data.currentPage, usercode: $('.case-hoof').val(), name: $('.name-hoof').val(), benginTime: benginTime, endTime: endTime},
                            beforeSend: function () {
                                Loading();
                            },
                            success: function (response) {
                                closeLoading();
                                if (response.responseCode == '1000') {
                                    if(response.content.list.length > 0){
                                        $('#ul-content').html('');
                                        for(var i = 0; i < response.content.list.length; i++){
                                            $('#ul-content').append('<li><span class="name" title="'+ nulls(response.content.list[i].usercode) +'">'+ nulls(response.content.list[i].usercode) +'</span><span class="ip" title="'+ nulls(response.content.list[i].ip) +'">'+ nulls(response.content.list[i].ip) +'</span><span class="content" title="'+ nulls(response.content.list[i].rzms) +'">'+ nulls(response.content.list[i].rzms) +'</span><span class="time" title="'+ nulls(response.content.list[i].czsj) +'">'+ nulls(response.content.list[i].czsj) +'</span></li>');
                                        }
                                    }else{
                                        Msg('暂无数据');
                                    }
                                }else{
                                    Msg();
                                }
                            },
                            error: function(){
                                closeLoading();
                                Msg();
                            }
                        })
                    }
                })
            }else{
                $('#demo_pag1').hide();
                Msg('暂无数据');
            }

        }else{
            Msg();
        }
    },
    error: function(){
        closeLoading();
        Msg();
    }
})
}
